package com.itheima.tlias84.utils;


//import lombok.AllArgsConstructor;
import lombok.Data;
//import lombok.NoArgsConstructor;

@Data
public class ResultUtil {
    private ResultUtil(){}
    private Integer code;
    private String msg;
    private Object data;

    /**
     * 默认成功方法
     * @return
     */
    public static ResultUtil success(){
        ResultUtil resultUtil = new ResultUtil();
        resultUtil.code=1;
        resultUtil.msg="success";
        return resultUtil;
    }

    /**
     * 携带自定义信息的返回
     */
    public static ResultUtil success(String msg){
        ResultUtil resultUtil = new ResultUtil();
        resultUtil.code=1;
        resultUtil.msg=msg;
        return resultUtil;
    }

    /**
     *携带数据的成功方法
     * @param data
     * @return
     */
    public static ResultUtil success(Object data){
        ResultUtil resultUtil = new ResultUtil();
        resultUtil.code=1;
        resultUtil.msg="success";
        resultUtil.data = data;
        return resultUtil;
    }

    public static ResultUtil success(String msg,Object data){
        ResultUtil resultUtil = new ResultUtil();
        resultUtil.code=1;
        resultUtil.msg=msg;
        resultUtil.data = data;
        return resultUtil;
    }

    //TODO 完成另外三个对应失败的

    public static ResultUtil fail(){
        ResultUtil resultUtil = new ResultUtil();
        resultUtil.code=0;
        resultUtil.msg="fail";
        return resultUtil;
    }

    /**
     * 携带自定义信息的返回
     */
    public static ResultUtil fail(String msg){
        ResultUtil resultUtil = new ResultUtil();
        resultUtil.code=0;
        resultUtil.msg=msg;
        return resultUtil;
    }


    /**
     *携带数据的成功方法
     * @param data
     * @return
     */
    public static ResultUtil fail(Object data){
        ResultUtil resultUtil = new ResultUtil();
        resultUtil.code=0;
        resultUtil.msg="fail";
        resultUtil.data = data;
        return resultUtil;
    }


    public static ResultUtil fail(String msg,Object data){
        ResultUtil resultUtil = new ResultUtil();
        resultUtil.code=0;
        resultUtil.msg=msg;
        resultUtil.data = data;
        return resultUtil;
    }

}
